﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using DAL;

namespace UI
{
    public partial class wiki : System.Web.UI.MasterPage
    {
        Controlador.Controladora controladora = new UI.Controlador.Controladora();
        protected void Page_Load(object sender, EventArgs e)
        {
            pnAdmin.Visible = false;

            if (Session["user"] != null)
            {
                lbCadastro.Visible = false;
                Usuario user = (Usuario)Session["user"];

                lbMeusPontos.Text += " " + user.pontos;

                if (user.PerfilUsuario.nome == "Administrador")
                {
                    pnAdmin.Visible = true;
                    lbLogin.Visible = false;
                }
                else
                {
                    pnAdmin.Visible = false;
                    lbLogin.Visible = true;
                }

                lbLogOut.Visible = true;
            }
            else
            {
                lbMeusPontos.Visible = false;
                lbMeusSeguidores.Visible = false;
                lbMinhasPostNews.Visible = false;
                lbLogOut.Visible = false;
            }
        }

        protected void lbCadastro_Click(object sender, EventArgs e)
        {
            Response.Redirect(controladora.GetSign());
        }

        protected void btSeach_Click(object sender, EventArgs e)
        {
            Response.Redirect(controladora.GetSimpleSearch() + "?parametro=" + txtSeach.Text);
        }

        protected void lbLogin_Click(object sender, EventArgs e)
        {
            Response.Redirect(new Controlador.Controladora().GetPageLogin());
        }

        protected void lbMeusSeguidores_Click(object sender, EventArgs e)
        {
            Response.Redirect(new Controlador.Controladora().GetConsultarSeguidores());
        }

        protected void lbLogOut_Click(object sender, EventArgs e)
        {
            Session["user"] = null;
            Response.Redirect(new Controlador.Controladora().GetHomePage());
        }

        protected void lbPostar_Click(object sender, EventArgs e)
        {
            Response.Redirect(new Controlador.Controladora().GetEditPostNew());
        }
    }
}
